<?php 
class Application_Model_TemporaryCart extends Application_Model_DomainObject {
    
    protected $_id;
    
    protected $_cartId; //购物车Id
    
    protected $_shopItemId; //商品Id

    protected $_shopNum; //商品数量
    
    protected $_shopName;//商品名称
    
    protected $_type;//类型
    
    protected $_userId;//用户Id
    
    protected $_dateCreated;//创建时间
    /**
     * 添加
     */
    const Type_Add = 1;
    /**
     * 删除
     */
    const Type_Delete = 2;
    /**
     * 修改
     */
    const Type_Edit = 3;
    /**
     * 提交代购
     */
    const Type_Submit = 4;


    public static function addTemporaryLog($cartId,$shopItemId,$shopName,$shopNum,$type,$userId)
    {
        $temporaryItem = new Application_Model_TemporaryCart();
        $temporaryItem->CartId = $cartId;
        $temporaryItem->ShopItemId = $shopItemId;
        $temporaryItem->ShopName = $shopName;
        $temporaryItem->ShopNum = $shopNum;
        $temporaryItem->Type = $type;
        $temporaryItem->UserId = $userId;
        $temporaryItem->DateCreated = date("Y-m=d H:i:s");
        $temporaryItem->save();
    }
    
    public static function getItemByUserIdType($userId,$type)
    {
        return self::getDao()->queryOne(array("userId = "=>$userId," and type = "=>$type));
    }
}